<template>
	<view class="content">
		<image class="bg-img" :src="app_img+'/app-img/user1.jpg'"></image>
		<view class="v-btn" >
			<button type="primary" size="mini" @click="scanCode()">扫码签到</button>
		</view>
		
	</view>
</template>

<script>
	import {updateQrcodeuser} from '@/api/qrcodeuser.js'
	export default {
		
		data() {
			return {
				app_img:this.appimg,
			}
		},
		onLoad() {
		},
		methods: {
			updateQrcodeuser(data){
				updateQrcodeuser(data).then(res=>{
					uni.showToast({title:'签到成功', icon:"none"});
				})
			},
			scanCode() {
				let that=this
			 // 允许从相机和相册扫码
			 uni.scanCode({
				 success: function (res) {
					 console.log('条码类型：' + res.scanType);
					 console.log('条码内容：' + res.result);
					 let data={
					 	 teachercard:'1222111111103',
					 	 userName:that.$store.state.user.user.userName
					  }
					 that.updateQrcodeuser(data)
				 },
				 fail:function(res){
					 //失败调用
				 },
				 complete:function(res){
					 //接口调用结束的回调函数（调用成功、失败都会执行）
				 },
			 });
			 
		}
    }
	}
</script>

<style scoped>
	page{
		height: 100%;
	}
	.content {
		flex: auto;
		display: flex;
		margin-top: 50%;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	
	

</style>
